package net.wanho.security.token;

import lombok.Data;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * Author：汤小洋
 * Date：2023-11-13 16:35
 * Description：<描述>
 */
public class JwtToken extends AbstractAuthenticationToken {

    private String token;

    public JwtToken(String token) {
        super(null);
        this.token = token;
        setAuthenticated(false); // 未认证
    }

    public JwtToken(String token, Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        this.token = token;
        setAuthenticated(true); // 已认证
    }

    @Override
    public Object getPrincipal() {
        return token;
    }

    @Override
    public Object getCredentials() {
        return token;
    }


}
